package com.liyunc.demo.model.dto;
/**
 * Copyright (c) 2018-2022 ThunderSoft
 * All Rights Reserved by Thunder Software Technology Co., Ltd and its affiliates.
 * You may not use, copy, distribute, modify, transmit in any form this file
 * except in compliance with ThunderSoft in writing by applicable law.
 */

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author liyuncong
 * @version 1.0
 * @file
 * @brief
 * @details
 * @date 2022-02-16
 *
 * Edit History
 * ----------------------------------------------------------------------------
 * DATE                     NAME               DESCRIPTION
 * 2022-02-16               liyuncong        Created
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class GenericDto<T> {
    @Schema(description = "响应码")
    private int code;
    @Schema(description = "响应信息")
    private String message;
    @Schema(description = "响应主体")
    private T payload;

    public static <T> GenericDto<T> of(int code, String message, T payload) {
        return new GenericDto<>(code, message, payload);
    }

    public static <T> GenericDto<T> of(T payload) {
        return new GenericDto<>(0, null, payload);
    }
}
